package com.ruoyi.web.controller.transferLog;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.transfer_log.domain.TransferLog;
import com.ruoyi.transfer_log.service.ITransferLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 交易日志Controller
 * 
 * @author 张富饶
 * @date 2025-05-21
 */
@RestController
@RequestMapping("/transfer_log/transfer_log")
public class TransferLogController extends BaseController
{
    @Autowired
    private ITransferLogService transferLogService;

    /**
     * 查询交易日志列表
     */
    @PreAuthorize("@ss.hasPermi('transfer_log:transfer_log:list')")
    @GetMapping("/list")
    public TableDataInfo list(TransferLog transferLog)
    {
        startPage();
        List<TransferLog> list = transferLogService.selectTransferLogList(transferLog);
        return getDataTable(list);
    }

    /**
     * 导出交易日志列表
     */
    @PreAuthorize("@ss.hasPermi('transfer_log:transfer_log:export')")
    @Log(title = "交易日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TransferLog transferLog)
    {
        List<TransferLog> list = transferLogService.selectTransferLogList(transferLog);
        ExcelUtil<TransferLog> util = new ExcelUtil<TransferLog>(TransferLog.class);
        util.exportExcel(response, list, "交易日志数据");
    }

    /**
     * 获取交易日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('transfer_log:transfer_log:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(transferLogService.selectTransferLogById(id));
    }

    /**
     * 新增交易日志
     */
    @PreAuthorize("@ss.hasPermi('transfer_log:transfer_log:add')")
    @Log(title = "交易日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TransferLog transferLog)
    {
        return toAjax(transferLogService.insertTransferLog(transferLog));
    }

    /**
     * 修改交易日志
     */
    @PreAuthorize("@ss.hasPermi('transfer_log:transfer_log:edit')")
    @Log(title = "交易日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TransferLog transferLog)
    {
        return toAjax(transferLogService.updateTransferLog(transferLog));
    }

    /**
     * 删除交易日志
     */
    @PreAuthorize("@ss.hasPermi('transfer_log:transfer_log:remove')")
    @Log(title = "交易日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(transferLogService.deleteTransferLogByIds(ids));
    }
}
